package leetcode_top;

import org.junit.Test;

public class Ex334 {
    class Solution {
        public boolean increasingTriplet(int[] nums) {
            int len = nums.length, min = 0,
             mid = 0;
            if (len < 3) return false;
            for (int i = 0; i < len - 2; i++) {
                if (nums[i] < nums[min]) {
                    min = i;
                } else if (nums[i] < nums[mid]) {
                    mid = i;
                }
                if (mid != min && nums[i] > nums[mid]) {
                    return true;
                }
            }
            return false;
        }
    }

    @Test
    public void test() {
        Solution s = new Solution();
        int[] nums = new int[]{2,4,-2,-3};
        System.out.println(s.increasingTriplet(nums));;
    }
    
}
